package com.sh.mapper;

import com.github.pagehelper.Page;
import com.sh.pojo.Article;
import com.sh.pojo.ArticlePageDto;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


@Mapper
public interface ArticleMapper {
    @Insert("insert into article(title,content,cover_img,state,category_id,create_user,create_time,update_time) " +
            "values (#{title},#{content},#{coverImg},#{state},#{categoryId},#{createUser},#{createTime},#{updateTime})")
    void add(Article article);

    Page<Article> list(ArticlePageDto articlePageDto);
    @Select("select * from article where id=#{id}")
    Article detail(Integer id);

    void update(Article article);
    @Delete("delete from article where id=#{id}")
    void delete(Integer id);

    @Select("select count(*) from article where category_id =#{id}")
    int count(Integer id);
}
